package com.itasura.redis.repository;

import com.itasura.redis.entity.Student;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
 * @author sailor wang
 * @date 2018/11/18 11:07 AM
 * @description
 */
public interface StudentRepository extends JpaRepository<Student, Integer> {

    //这里的单引号不能少，否则会报错，被识别是一个对象;
    @Cacheable(value = "studentCache", key = "'stu_'+#p0")
    List<Student> findByStuNo(String stuNo);


    @CacheEvict(value = "studentCache", key = "'stu_'+#p0")
    void deleteByStuNo(String stuNo);
}
